home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kate / view.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  8.7 KB  |  304 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18.  
  19. #ifndef _KATE_VIEW_INCLUDE_
  20. #define _KATE_VIEW_INCLUDE_
  21.  
  22. #include <ktexteditor/document.h>
  23. #include <ktexteditor/view.h>
  24. #include <ktexteditor/clipboardinterface.h>
  25. #include <ktexteditor/popupmenuinterface.h>
  26. #include <ktexteditor/markinterface.h>
  27. #include <ktexteditor/viewcursorinterface.h>
  28. #include <ktexteditor/codecompletioninterface.h>
  29. #include <ktexteditor/dynwordwrapinterface.h>
  30.  
  31. class KConfig;
  32.  
  33. namespace Kate
  34. {
  35.  
  36. class Document;
  37.  
  38. /**
  39.   The Kate::View text editor interface.
  40.   @author Cullmann Christoph, modified by rokrau (6/21/01)
  41. */
  42. class KATEPARTINTERFACES_EXPORT View : public KTextEditor::View, public KTextEditor::ClipboardInterface,
  43.               public KTextEditor::PopupMenuInterface, public KTextEditor::ViewCursorInterface,
  44.               public KTextEditor::CodeCompletionInterface, public KTextEditor::DynWordWrapInterface
  45. {
  46.   Q_OBJECT
  47.  
  48.   public:
  49.     /**
  50.      Return values for "save" related commands.
  51.     */
  52.     enum saveResult { SAVE_OK, SAVE_CANCEL, SAVE_RETRY, SAVE_ERROR };
  53.     /**
  54.      Constructor (should much rather take a reference to the document).
  55.     */
  56.     View ( KTextEditor::Document *, QWidget *, const char *name = 0 );
  57.     /**
  58.      Destructor, you need a destructor if Scott Meyers says so.
  59.     */
  60.     virtual ~View ();
  61.     /**
  62.      Set editor mode
  63.     */
  64.     virtual bool isOverwriteMode() const  { return false; }
  65.     /**
  66.      Get editor mode
  67.     */
  68.     virtual void setOverwriteMode( bool ) { }
  69.     /**
  70.       Gets the text line where the cursor is on
  71.     */
  72.     virtual QString currentTextLine() { return 0L; }
  73.     /**
  74.       Gets the word where the cursor is on
  75.     */
  76.     virtual QString currentWord() { return 0L; }
  77.     /**
  78.       Gets the word at position x, y. Can be used to find
  79.       the word under the mouse cursor
  80.     */
  81.     virtual QString word(int , int ) { return 0L; }
  82.     /**
  83.       Insert text at the current cursor position.
  84.       @param mark is unused.
  85.     */
  86.     virtual void insertText(const QString &mark ) { Q_UNUSED(mark); }
  87.     /**
  88.       Works exactly like closeURL() of KParts::ReadWritePart
  89.     */
  90.     virtual bool canDiscard() { return false; }
  91.  
  92.   public:
  93.     virtual int tabWidth() = 0;
  94.     virtual void setTabWidth(int) = 0;
  95.     virtual void setEncoding (QString e) = 0;
  96.  
  97.     /**
  98.       Returns true if this editor is the only owner of its document
  99.     */
  100.     virtual bool isLastView() = 0;
  101.  
  102.   public slots:
  103.     /**
  104.      Flushes the document of the text widget. The user is given
  105.      a chance to save the current document if the current document has
  106.      been modified.
  107.     */
  108.     virtual void flush () { ; };
  109.     /**
  110.       Saves the file under the current file name. If the current file
  111.       name is Untitled, as it is after a call to newFile(), this routine will
  112.       call saveAs().
  113.     */
  114.     virtual saveResult save() { return SAVE_CANCEL; };
  115.     /**
  116.       Allows the user to save the file under a new name.
  117.     */
  118.     virtual saveResult saveAs() { return SAVE_CANCEL; };
  119.     /**
  120.       Moves the current line or the selection one position to the right.
  121.     */
  122.     virtual void indent() { ; };
  123.     /**
  124.       Moves the current line or the selection one position to the left.
  125.     */
  126.     virtual void unIndent() { ; };
  127.     /**
  128.       Optimizes the selected indentation, replacing tabs and spaces as needed.
  129.     */
  130.     virtual void cleanIndent() { ; };
  131.     /**
  132.       Comments out current line.
  133.     */
  134.     virtual void comment() { ; };
  135.     /**
  136.       Removes comment signs in the current line.
  137.     */
  138.     virtual void uncomment() { ; };
  139.     /**
  140.       Some simply key commands.
  141.     */
  142.     virtual void keyReturn () { ; };
  143.     virtual void keyDelete () { ; };
  144.     virtual void backspace () { ; };
  145.     virtual void killLine () { ; };
  146.     /**
  147.       Move cursor in the view
  148.     */
  149.     virtual void cursorLeft () { ; };
  150.     virtual void shiftCursorLeft () { ; };
  151.     virtual void cursorRight () { ; };
  152.     virtual void shiftCursorRight () { ; };
  153.     virtual void wordLeft () { ; };
  154.     virtual void shiftWordLeft () { ; };
  155.     virtual void wordRight () { ; };
  156.     virtual void shiftWordRight () { ; };
  157.     virtual void home () { ; };
  158.     virtual void shiftHome () { ; };
  159.     virtual void end () { ; };
  160.     virtual void shiftEnd () { ; };
  161.     virtual void up () { ; };
  162.     virtual void shiftUp () { ; };
  163.     virtual void down () { ; };
  164.     virtual void shiftDown () { ; };
  165.     virtual void scrollUp () { ; };
  166.     virtual void scrollDown () { ; };
  167.     virtual void topOfView () { ; };
  168.     virtual void bottomOfView () { ; };
  169.     virtual void pageUp () { ; };
  170.     virtual void shiftPageUp () { ; };
  171.     virtual void pageDown () { ; };
  172.     virtual void shiftPageDown () { ; };
  173.     virtual void top () { ; };
  174.     virtual void shiftTop () { ; };
  175.     virtual void bottom () { ; };
  176.     virtual void shiftBottom () { ; };
  177.     /**
  178.       Presents a search dialog to the user.
  179.     */
  180.     virtual void find() { ; };
  181.     /**
  182.       Presents a replace dialog to the user.
  183.     */
  184.     virtual void replace() { ; };
  185.     /**
  186.       Presents a "Goto Line" dialog to the user.
  187.     */
  188.     virtual void gotoLine() { ; };
  189.  
  190.   public:
  191.     /**
  192.       Reads session config out of the KConfig object. This also includes
  193.       the actual cursor position and the bookmarks.
  194.     */
  195.     virtual void readSessionConfig(KConfig *) { ; };
  196.     /**
  197.       Writes session config into the KConfig object.
  198.     */
  199.     virtual void writeSessionConfig(KConfig *) { ; };
  200.  
  201.   public slots:
  202.     /**
  203.       Get the end of line mode (Unix, Macintosh or Dos).
  204.     */
  205.     virtual int getEol() { return 0L; }
  206.     /**
  207.       Set the end of line mode (Unix, Macintosh or Dos).
  208.     */
  209.     virtual void setEol(int) { }
  210.     /**
  211.       Set focus to the current window.
  212.     */
  213.     // Should remove this, it's redundant.
  214.     virtual void setFocus () { QWidget::setFocus(); }
  215.     /**
  216.       Searches for the last searched text forward from cursor position.
  217.       @param forward determines the search direction.
  218.     */
  219.     virtual void findAgain(bool forward ) { Q_UNUSED(forward); }
  220.     /**
  221.       Searches for the last searched text forward from cursor position.
  222.       Searches forward from current cursor position.
  223.     */
  224.     virtual void findAgain () { };
  225.     /**
  226.       Searches for the last searched text forward from cursor position.
  227.       Searches backward from current cursor position.
  228.     */
  229.     virtual void findPrev () { }
  230.     /**
  231.       Presents an edit command popup window, where the user can
  232.       apply a shell command to the contents of the current window.
  233.     */
  234.     virtual void slotEditCommand () { }
  235.  
  236.     /**
  237.       Sets icon border on or off depending on
  238.       @param enable the flag
  239.     */
  240.     virtual void setIconBorder (bool enable ) { Q_UNUSED(enable); }
  241.     /**
  242.       Toggles icon border.
  243.     */
  244.     virtual void toggleIconBorder () { }
  245.     /**
  246.       Sets display of line numbers on/off depending on @p enable
  247.       @param enable the flag
  248.     */
  249.     virtual void setLineNumbersOn (bool enable) { Q_UNUSED(enable); }
  250.     /**
  251.       Toggles display of lineNumbers
  252.     */
  253.     virtual void toggleLineNumbersOn () {}
  254.  
  255.   public:
  256.     /**
  257.       Returns whether iconborder is visible.
  258.     */
  259.     virtual bool iconBorder() { return false; }
  260.     /**
  261.       @return Wheather line numbers display is on
  262.     */
  263.     virtual bool lineNumbersOn() { return false; }
  264.     /**
  265.      Returns a pointer to the document of the view.
  266.     */
  267.     virtual Document *getDoc () { return 0L; }
  268.  
  269.   public slots:
  270.     /**
  271.       Increase font size.
  272.     */
  273.     virtual void slotIncFontSizes () { }
  274.     /**
  275.       Decrease font size.
  276.     */
  277.     virtual void slotDecFontSizes () { }
  278.  
  279.     virtual void gotoMark (KTextEditor::Mark *mark) = 0;
  280.  
  281.     /**
  282.      * @deprecated No longer does anything. Use KTextEditor
  283.      * equivalents
  284.      */
  285.     // TODO: Remove when BIC is allowed
  286.     virtual void toggleBookmark () {}
  287.  
  288.     virtual void gotoLineNumber( int ) = 0;
  289.  
  290.   signals:
  291.     void gotFocus (View *);
  292. //  void newStatus(); // Kate app connects to this signal, should be in the interface
  293.  
  294.   public:
  295.     virtual void setActive (bool b) = 0;
  296.     virtual bool isActive () = 0;
  297. };
  298.  
  299. KATEPARTINTERFACES_EXPORT View *view (KTextEditor::View *view);
  300.  
  301. }
  302.  
  303. #endif
  304.